using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// Purview_Exception - 权限特殊处理表 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IPurviewException<T> :ModelBase<PurviewException> where T : PurviewException, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.UserAndPwId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return UserAndPwId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.UserAndPwId=dy.UserAndPwId;
           this.UserId=dy.UserId;
           this.PwId=dy.PwId;
           this.Type=dy.Type;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 权限特殊处理ID
        /// </summary>
        private String _UserAndPwId = "";
      
        /// <summary>
        /// 权限特殊处理ID
        /// </summary>
        public String UserAndPwId
        {
            get 
            {
              return   (this._UserAndPwId); 
            }

            set 
            {
                    _UserAndPwId= value;  
            }
        }
       
     
         /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";
      
        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get 
            {
              return   (this._UserId); 
            }

            set 
            {
                    _UserId= value;  
            }
        }
       
     
         /// <summary>
        /// 权限ID
        /// </summary>
        private String _PwId = "";
      
        /// <summary>
        /// 权限ID
        /// </summary>
        public String PwId
        {
            get 
            {
              return   (this._PwId); 
            }

            set 
            {
                    _PwId= value;  
            }
        }
       
     
         /// <summary>
        /// 类型
        /// </summary>
        private int _Type =-1;
      
        /// <summary>
        /// 类型
        /// </summary>
        public yq.Enums.PurviewException.Type Type
        {
            get 
            {
              return   (yq.Enums.PurviewException.Type)this._Type;  
            }

            set 
            {
                    _Type= value.GetHashCode(); 
            }
        }
       
     
      

      #endregion 定义属性 

          protected internal override void SetValue(PurviewException info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["UserAndPwId"]!= DBNull.Value)
                  {
                  info.UserAndPwId=row["UserAndPwId"].ToString();
                 }
                 
                  
                  if(row["UserId"]!= DBNull.Value)
                  {
                  info.UserId=row["UserId"].ToString();
                 }
                 
                  
                  if(row["PwId"]!= DBNull.Value)
                  {
                  info.PwId=row["PwId"].ToString();
                 }
                 
                  
                  if(row["Type"]!= DBNull.Value)
                  {
                  info.Type=  (yq.Enums.PurviewException.Type)(row["Type"]) ;
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, PurviewException info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@UserAndPwId", DbType.String,ParameterTool.GetObj( info._UserAndPwId )); 
            
             
                cn.AddInParameter(comm, "@UserId", DbType.String,ParameterTool.GetObj( info._UserId )); 
            
             
                cn.AddInParameter(comm, "@PwId", DbType.String,ParameterTool.GetObj( info._PwId )); 
            
             
                cn.AddInParameter(comm, "@Type", DbType.Int32,ParameterTool.GetObj( info._Type )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 